From c845b8438b65e6735c8beb0927ad0527cb1b0611 Mon Sep 17 00:00:00 2001
From: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
Date: Fri, 7 Mar 2014 14:44:03 +0100
Subject: [PATCH] Do not use the system ninja

Always bootstrap and use the bundled ninja to avoid incompatibilities
between our bundled gyp and the system ninja, which might be quite
old.

This patch also removes the ninja location caching, as updating the
cache would trigger a re-run of qmake and gyp on all the project,
while the benefit of using the cache in this case are low.

Change-Id: I843cbe20e1153caecbda00ab3d45a34d560b2423
Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Reviewed-by: Zoltan Arvai <zarvai@inf.u-szeged.hu>
---
 tools/qmake/mkspecs/features/functions.prf | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/tools/qmake/mkspecs/features/functions.prf b/tools/qmake/mkspecs/features/functions.prf
index 0814e8b..4dcd8ed 100644
--- a/tools/qmake/mkspecs/features/functions.prf
+++ b/tools/qmake/mkspecs/features/functions.prf
@@ -84,23 +84,16 @@ defineReplace(which) {
 }
 
 defineReplace(findOrBuildNinja) {
-  !isEmpty(CACHED_NINJA_EXECUTABLE):exists($$CACHED_NINJA_EXECUTABLE): return($$CACHED_NINJA_EXECUTABLE)
-  out = $$which(ninja)
-  # Try to be smart about it if we know where the chromium sources are located
-  !exists($$out) {
     git_chromium_src_dir = $$system("git config qtwebengine.chromiumsrcdir")
     # Fall back to the snapshot path if git does not know about chromium sources (i.e. init-repository.py has not been used)
     isEmpty(git_chromium_src_dir): git_chromium_src_dir = "src/3rdparty/chromium"
-    win32: out = $$system_path($$absolute_path("$$git_chromium_src_dir/../ninja/ninja.exe", "$$QTWEBENGINE_ROOT"))
-    else: out = $$absolute_path("$$git_chromium_src_dir/../ninja/ninja", "$$QTWEBENGINE_ROOT")
-    # If we still did not find ninja, then we bootstrap it.
+
+    out = $$absolute_path("$$git_chromium_src_dir/../ninja/ninja", "$$QTWEBENGINE_ROOT")
+    win32: out = $$system_path($${out}.exe)
+
+    # If we did not find ninja, then we bootstrap it.
     !exists($$out) {
-      message("bootstrapping ninja...")
-      ninjadir = $$dirname(out)
-      system("python $$ninjadir/bootstrap.py")
+        system("python $$dirname(out)/bootstrap.py")
     }
-  }
-  message("using $$out")
-  cache(CACHED_NINJA_EXECUTABLE, set, out)
-  return($$out)
+    return($$out)
 } 
